<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/common/public.jsp" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>编辑食品</title>
</head>
<script type="text/javascript" src="${ctx}/js/checkFrom.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#foodName").change(function(){
			var url="${ctx}/food/getList"
			$.get(url,function(data,status){
				if(status=="success"){
					var foodName=$("#foodName").val();
					var oName=$("#oName").val();
					var obj=eval(data);
					for(var i=0;i<obj.length;i++){
						if(obj[i].foodName==foodName){
							if(foodName!=oName){
								$("#foodName").val("");
								alert(foodName+"已经存在不能重复添加");

							}

						}
					}
				}
			});
		});
	});
</script>
<body>
<a href="${ctx}/food/list">返回食品列表</a>
<hr />
<form action="${ctx }/food/update" method="post"  name="myform">
<input type="hidden" name="foodId" value="${food.foodId}">
	<table class="t1">
		<tr>
			<td>食品名称</td>
			<input type="hidden"  id="oName" value="${food.foodName}" />
			<td><input type="text" name="foodName" required id="foodName" value="${food.foodName}" /></td>
		</tr>
		<tr>
			<td>分类名称</td>
			<input type="hidden" name="classId"  value="${food.classId}"/>
			<td><input type="text" name="className" required readonly value="${food.className}" /></td>

			</td>
		</tr>
		<tr>
			<td>规格</td>
			<td><input type="text" name="foodStandard" value="${food.foodStandard}" /></td>
		</tr>

		<tr>
			<td>备注</td>
			<td><input type="text" name="remarks" value="${food.remarks}" /></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" value="保存"> </td>
		</tr>
	</table>
</form>
</body>
</html>